package com.cnhis.cloudhealth.clinical.hosnurse.hostreatment.bo;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cnhis.cloudhealth.clinical.hosnurse.hostreatment.dao.HosTreatmentDao;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.utils.JsonUtil;
import com.cnhis.cloudhealth.commons.utils.StaticKeys;

@Service
public class HosTreatmentBo
{
    @Resource
    private HosTreatmentDao hosTreatmentDao;
    
    public ModelVo herbDetail(Map map)
        throws Exception
    {
        ModelVo mo = new ModelVo();
        List list = null;
        try
        {
            list = hosTreatmentDao.herbDetail(map);
            
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mo.setResult(StaticKeys.OH_FALSE);
            return mo;
        }
        mo.setList(list);
        mo.setResult(StaticKeys.OH_SUCCESS);
        mo.setRows(list);
        return mo;
    }
    
    public ModelVo exec_Nurse_Ivggt_Bills_Print_Ok(Map map)
    {
        ModelVo mo = new ModelVo();
        try
        {
            String type = map.get("lType").toString();
            int typeI = Integer.parseInt(type);
            String vbiArr = map.get("vbiArr").toString();
            List<Map<String,Object>> vbiList = JsonUtil.getList(vbiArr);
            if (vbiList!=null && !vbiList.isEmpty())
            {
                map.put("vbiList", vbiList);
                if (typeI == 0)
                {
                    hosTreatmentDao.update("HosTreatment.updateVbi0", map);
                }
                else if (typeI == 1)
                {
                    hosTreatmentDao.update("HosTreatment.updateVbi1", map);
                }
                else if (typeI > 1)
                {
                    hosTreatmentDao.update("HosTreatment.updateVbiOther", map);
                } 
            }
            mo.setResult(StaticKeys.OH_SUCCESS);
            return mo;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mo.setResult(StaticKeys.OH_FALSE);
            return mo;
        }
    }

    public ModelVo exec_Nurse_Lis_Bills_Print_Ok(Map map)
    {
        ModelVo mo = new ModelVo();
        try
        {
            String bda01 = map.get("bda01").toString();
            String vaf01Arr = map.get("vaf01Arr").toString();
            List<Map<String,Object>> vbiList = JsonUtil.getList(vaf01Arr);
            if (vbiList!=null && !vbiList.isEmpty())
            {
                map.put("vbiList", vbiList);
                hosTreatmentDao.update("HosTreatment.exec_Nurse_Lis_Bills_Print_Ok", map);
            }
            mo.setResult(StaticKeys.OH_SUCCESS);
            return mo;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mo.setResult(StaticKeys.OH_FALSE);
            return mo;
        }
    }

    public ModelVo getVbi01s(Map map)
    {
        ModelVo mo = new ModelVo();
        try
        {
            List list = hosTreatmentDao.queryForList("HosTreatment.getVbi01s", map);
            mo.setResult(StaticKeys.OH_SUCCESS);
            mo.setList(list);
            return mo;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mo.setResult(StaticKeys.OH_FALSE);
            return mo;
        }
    }
}
